﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using XCommon.Types;

namespace XWeb
{
    public partial class order : Code.Page.UIBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void AddOrder()
        {
            int nType = 0, nCount = 0, nUserID = 0;
            string sNumber;
            int.TryParse(this.GetValue(Code.XConst.S_KEY_TYPE), out nType);
            int.TryParse(this.GetValue(Code.XConst.S_KEY_COUNT), out nCount);
            int.TryParse(this.GetValue(Code.XConst.S_KEY_USERID), out nUserID);
            sNumber = this.GetValue(Code.XConst.S_KEY_NUMBER);

            Ps ps = new Ps();
            ps.Add(XModel.Keys.KEY_TBORDER_TYPE, nType.ToString());
            ps.Add(XModel.Keys.KEY_TBORDER_COUNT, nCount.ToString());
            ps.Add(XModel.Keys.KEY_TBORDER_NUMBER, sNumber);
            ps.Add(XModel.Keys.KEY_TBORDER_USERID, nUserID.ToString());

            bool bRet = XDAL.tbOrder.It.Insert(ps);
            this.WriteOut(bRet.ToString(), HTMLContentType.JSON);
        }

        public void GetOrder()
        {
            int nUserID = 0;
            int.TryParse(this.GetValue(Code.XConst.S_KEY_USERID), out nUserID);
            if (nUserID == 0) return;
            List<Ps> ps = XDAL.tbOrder.It.Get(nUserID);
            if (ps == null || ps.Count <= 0) return;
            this.WriteOut(XCommon.LitJson.JsonMapper.ToJson(ps), HTMLContentType.JSON);
        }

    }
}